Release 10.1A: OpenEdge Development:
ProDataSets


Doing a partial ProDataSet FILL to return Order headers

This code example continues over the following sections, each of which illustrates and explains parts of the overall procedure. When the user enters values for one or more of the filtering fields, the window procedure will format that into a where-clause and pass that to a new internal procedure called fetchOrders that returns the ProDataSet. Add this code for fetchOrders to OrderSupport.p:

PROCEDURE fetchOrders: 
     DEFINE INPUT  PARAMETER pcSelection AS CHARACTER  NO-UNDO. 
     DEFINE OUTPUT PARAMETER DATASET FOR dsOrder BY-VALUE. 
      
     cSelection = pcSelection. 
     hDataSet:EMPTY-DATASET. 
     hDataSet:GET-BUFFER-HANDLE(2):FILL-MODE = "NO-FILL".   /* ttOline */ 
     hDataSet:GET-BUFFER-HANDLE(3):FILL-MODE = "NO-FILL".   /* ttItem  */ 
     hDataSet:FILL(). 
      
END PROCEDURE. 

This saves off the selection criteria and empties the server-side ProDataSet in preparation for responding to the request.

When the user requests a set of Orders, you don’t want to return all the OrderLine detail yet because that can be a lot of data. Instead, you just return the Order headers and wait for the user to select a specific Order to fill in. For this reason fetchOrders needs to set the FILL-MODE attribute for the ttOline and ttItem tables to “NO-FILL.” In this way, when you then do a FILL on the ProDataSet, it fills only the ttOrder table and skips the other two tables.

There are three ways to change the extent of a FILL, either to limit or to extend the amount of data loaded into the ProDataSet at one time:

This different behavior for a FILL on a buffer is there specifically to provide you with enough alternatives to satisfy just about any requirement. There is almost always more than one way to get the level of FILL that you want. Don’t be unduly confused by all the alternatives. Just pick a way that works for your situation.

To show you an example of one alternative to the one the example uses, the code in fetchOrders could deactivate the first relation in the ProDataSet, between ttOrder and ttOline. In this case, you would have to do the FILL on the ttOrder buffer rather than on the ProDataSet. Otherwise, the ttOrder and ttItem tables would be filled with all the OrderLines and Items in the database, which is not what you want. So the code would look like this:

 /* Instead of these statements… 
     hDataSet:GET-BUFFER-HANDLE(2):FILL-MODE = "NO-FILL". /* ttOline */ 
     hDataSet:GET-BUFFER-HANDLE(3):FILL-MODE = "NO-FILL". /* ttItem  */ 
     hDataSet:FILL(). 
     --- you could use these statements to accomplish the same thing: */ 
     hDataSet:GET-RELATION(1):ACTIVE = NO. 
     hDataSet:GET-BUFFER-HANDLE(1):FILL(). 

Note, again, that in this case you do the FILL on the first buffer handle, not on the ProDataSet. Also, you have to remember to set the ACTIVE attribute back to TRUE when you need to fill the detail later on.

Another point to remember in this case is that any event procedures defined at the level of the ProDataSet will not fire when you do a FILL on the ttOrder table. In our example, the support procedure prepares the Order query in the BEFORE-FILL event for the ProDataSet and detaches the Data-Sources in the AFTER-EVENT for the ProDataSet, so this code would need to be moved to the FILL events for the Order table. These are all things to consider when you are designing the structure of your procedures and event handlers.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095